Skip to content

Clear active CastSession on session start/resume failure - #3581

Open
sahuadarsh0 wants to merge 1 commit into
androidx:mainfrom
sahuadarsh0:fix/3580-remote-cast-player-session-failed
Open

sahuadarsh0 wants to merge 1 commit into
androidx:mainfrom
sahuadarsh0:fix/3580-remote-cast-player-session-failed

Conversation

@sahuadarsh0

Copy link
Copy Markdown

Root cause

RemoteCastPlayer.StatusListener.onSessionStartFailed and onSessionResumeFailed only logged the status code and left castSession / remoteMediaClient attached. When the Cast SDK reports a start or resume failure for an already-active session (e.g., after a Wi-Fi drop without onSessionSuspended or onSessionEnded), RemoteCastPlayer retained the dead session and never notified SessionAvailabilityListener.onCastSessionUnavailable, preventing CastPlayer from transferring playback back to the local player.

Changes

  • In RemoteCastPlayer.StatusListener.onSessionStartFailed and onSessionResumeFailed, clear the session with setCastSession(null, SessionAvailabilityListener.SESSION_UNAVAILABLE_REASON_DISCONNECTED) when castSession matches the currently held RemoteCastPlayer.this.castSession.
  • Ignore failures reported for a different CastSession instance so an unrelated active session is not torn down.
  • Add unit tests in RemoteCastPlayerTest (matching and non-matching sessions for both callbacks) and CastPlayerTest (transfer back to local player with pause).
  • Add a release note entry in RELEASENOTES.md.

Testing

  • Verified the 4 new failure tests failed before the fix and passed after.
  • Ran ./gradlew :lib-cast:testDebugUnitTest --no-daemon (all tests pass).

Fixes #3580

When the Cast SDK reports onSessionStartFailed or onSessionResumeFailed
for the CastSession currently held by RemoteCastPlayer (for example after
a network drop without onSessionSuspended/onSessionEnded), clear the
session and notify SessionAvailabilityListener with
SESSION_UNAVAILABLE_REASON_DISCONNECTED so CastPlayer transfers playback
back to the local player.

Failures reported for a different CastSession are ignored so an unrelated
active session is not disrupted.

Fixes androidx#3580
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants